<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta content="yes" name="apple-touch-fullscreen">
    <meta content="telephone=no,email=no" name="format-detection">
    <script src="http://g.tbcdn.cn/mtb/lib-flexible/0.3.4/??flexible_css.js,flexible.js"></script>
    <link rel="stylesheet" href="../css/style.css"/>
    <script src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
    <script src="../js/fastclick.js"></script>
    <script>
        window.addEventListener('load', function () {
            FastClick.attach(document.body);
        }, false);
    </script>
</head>
<body>
<div class="bar">
    <a class="left-label" href="javascript:history.back();">
        <div class="icon left">
            <div class="icon-left left"></div>
        </div>
        <div class="toBack left">返回</div>
    </a>
</div>
<div class="content">
    <div class="top-box">
        <div class="t-title">输入手机号码</div>
        <div class="tip-text">登录即代表阅读并同意<a href="">注册协议</a></div>
    </div>
    <div class="form-box">
        <div class="input-group">
            <input type="number"
                   class="flex-bd"
                   id="mobile"
                   placeholder="手机号"
                   pattern="[0-9]*"
            />
        </div>
        <div class="button">加入我们</div>
    </div>
</div>
<div class="toolTip"></div>
<script>
    var ip = 'http://www.mk319.com:9090';
    //var ip='http://localhost';
    $('.button').on('click', function () {
        var mobile = $('#mobile').val();
        if (sessionStorage['invitedCode']) {
            if ((/^1[34578]\d{9}$/).test(mobile)) {
                var req = {
                    'phone': mobile,
                    'invitedCode': sessionStorage['invitedCode']
                };
                $.ajax({
                    url: ip + '/api/open/member/preSignUp',
                    type: 'post',
                    data: req,
                    dataType: 'json',
                    success: function (res) {
                        toolTip(res.message);
                        if (res.status == 900000) {
                            setTimeout(function () {
                                location.href = 'download.html';
                            }, 3000);
                        }
                    },
                    error: function () {
                        toolTip(res.message);
                    }
                });
            } else {
                toolTip('手机号码错误');
            }
        } else {
            toolTip('邀请码有误！');
        }
    });
    function toolTip(msg) {
        $('.toolTip').text(msg).fadeIn();
        setTimeout(function () {
            $('.toolTip').fadeOut();
        }, 2000);
    }
</script>
</body>
</html>
